Package com.cisco.pt.ptmp.impl
Class PacketTracerConnectionImpl
java.lang.Object
com.cisco.pt.ptmp.impl.PacketTracerConnectionImpl
- All Implemented Interfaces:
PacketTracerConnection
- Author:
- packettracerexapps@external.cisco.com
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPacketTracerConnectionImpl(String host, int port) Create a Packet Tracer connection with ConnectionNegotiationProperties from properties filePacketTracerConnectionImpl(String host, int port, ConnectionNegotiationProperties connectionNegotiationProperties) Create a Packet Tracer connection with ConnectionNegotiationProperties -
Method Summary
Modifier and TypeMethodDescriptionbooleanconnect()Open a socket channel on the specified host:portvoidvoidClose the underlying socket channelvoidgetHost()intintgetPort()intintprotected voidprotected voidprotected intinnerRead(ByteBuffer byteBuffer) protected intinnerWrite(ByteBuffer byteBuffer) booleanReturns true if the underlying socket connection is not null and is connectedbooleanisDown()booleanisOpen()booleanisUp()voidintread(ByteBuffer byteBuffer) Uses the underlying socket channel to read the byte bufferbooleanvoidprotected voidprotected voidintwrite(ByteBuffer byteBuffer) Uses the underlying socket channel to write the byte buffer
-
Field Details
-
readCount
protected int readCount -
writeCount
protected int writeCount -
lowLevelReadErrorCount
protected int lowLevelReadErrorCount -
readThread
-
currentStatus
-
currentStatusReason
-
currentStatusThrowable
-
STATUS_CLOSED
-
STATUS_DOWN
-
STATUS_NEW
-
STATUS_UP
-
-
Constructor Details
-
PacketTracerConnectionImpl
Create a Packet Tracer connection with ConnectionNegotiationProperties from properties file- Parameters:
host- Packet Tracer hostport- Packet Tracer port
-
PacketTracerConnectionImpl
public PacketTracerConnectionImpl(String host, int port, ConnectionNegotiationProperties connectionNegotiationProperties) Create a Packet Tracer connection with ConnectionNegotiationProperties- Parameters:
host- Packet Tracer hostport- Packet Tracer portconnectionNegotiationProperties- Connection negotiation properties
-
-
Method Details
-
connect
public boolean connect()Description copied from interface:PacketTracerConnectionOpen a socket channel on the specified host:port- Specified by:
connectin interfacePacketTracerConnection- Returns:
- true if connection succeeded
-
reconnect
public boolean reconnect()- Specified by:
reconnectin interfacePacketTracerConnection
-
connectLowLevelReadThread
public void connectLowLevelReadThread()- Specified by:
connectLowLevelReadThreadin interfacePacketTracerConnection
-
reconnectLowLevelReadThread
public void reconnectLowLevelReadThread()- Specified by:
reconnectLowLevelReadThreadin interfacePacketTracerConnection
-
disconnectLowLevelReadThread
public void disconnectLowLevelReadThread()- Specified by:
disconnectLowLevelReadThreadin interfacePacketTracerConnection
-
disconnect
public void disconnect()Description copied from interface:PacketTracerConnectionClose the underlying socket channel- Specified by:
disconnectin interfacePacketTracerConnection
-
isUp
public boolean isUp()- Specified by:
isUpin interfacePacketTracerConnection
-
isDown
public boolean isDown()- Specified by:
isDownin interfacePacketTracerConnection
-
getCurrentStatus
- Specified by:
getCurrentStatusin interfacePacketTracerConnection
-
getCurrentStatusReason
- Specified by:
getCurrentStatusReasonin interfacePacketTracerConnection
-
getCurrentStatusThrowable
- Specified by:
getCurrentStatusThrowablein interfacePacketTracerConnection
-
isConnected
public boolean isConnected()Description copied from interface:PacketTracerConnectionReturns true if the underlying socket connection is not null and is connected- Specified by:
isConnectedin interfacePacketTracerConnection- Returns:
- boolean if successful
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfacePacketTracerConnection
-
getNextMessage
- Specified by:
getNextMessagein interfacePacketTracerConnection- Throws:
IOExceptionInterruptedException
-
read
Description copied from interface:PacketTracerConnectionUses the underlying socket channel to read the byte buffer- Specified by:
readin interfacePacketTracerConnection- Parameters:
byteBuffer- ByteBuffer- Returns:
- number of bytes read
- Throws:
IOException- The exception
-
innerRead
- Throws:
IOException
-
write
Description copied from interface:PacketTracerConnectionUses the underlying socket channel to write the byte buffer- Specified by:
writein interfacePacketTracerConnection- Parameters:
byteBuffer- ByteBuffer- Returns:
- number of bytes written
- Throws:
IOException- The exception
-
innerWrite
- Throws:
IOException
-
getHost
- Specified by:
getHostin interfacePacketTracerConnection- Returns:
- host name (e.g. localhost)
-
getPort
public int getPort()- Specified by:
getPortin interfacePacketTracerConnection- Returns:
- port number (e.g. 39000)
-
socketChannel
- Specified by:
socketChannelin interfacePacketTracerConnection- Returns:
- the underlying socket channel
-
connectionNegotiationProperties
- Specified by:
connectionNegotiationPropertiesin interfacePacketTracerConnection- Returns:
- the connection negotiation properties for this connection
-
getLowLevelReadErrorCount
public int getLowLevelReadErrorCount() -
noteLowLevelReadError
- Specified by:
noteLowLevelReadErrorin interfacePacketTracerConnection
-
getWriteCount
public int getWriteCount() -
incrementWriteCount
protected void incrementWriteCount() -
getReadCount
public int getReadCount() -
incrementReadCount
protected void incrementReadCount() -
setStatus
-
setStatus
-